/////////////////////////////////////////////////////////////////////////////
// Name:        custompronunciationdialog.h
// Purpose:     
// Author:      Julian Smart
// Modified by: 
// Created:     11/02/2009 20:01:56
// RCS-ID:      
// Copyright:   (c) Anthemion Software Limited
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _CUSTOMPRONUNCIATIONDIALOG_H_
#define _CUSTOMPRONUNCIATIONDIALOG_H_

/*
 * Includes
 */

////@begin includes
#include "wx/html/htmlwin.h"
////@end includes

#include "tts/tts.h"

/*
 * Forward declarations
 */

////@begin forward declarations
class wxBoxSizer;
class wxTTSHtmlWindow;
////@end forward declarations

/*
 * Control identifiers
 */

////@begin control identifiers
#define SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL
#define SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_TITLE _("Custom Pronunciations")
#define SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_IDNAME ID_CUSTOMPRONUNCIATIONDIALOG
#define SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_SIZE wxSize(400, 300)
#define SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_POSITION wxDefaultPosition
////@end control identifiers

// An HTML window
class wxTTSHtmlWindow: public wxHtmlWindow
{
public:
    wxTTSHtmlWindow(wxWindow* parent, wxWindowID id,
        const wxPoint& pos, const wxSize& size, long style);

    virtual void OnLinkClicked(const wxHtmlLinkInfo& info);
    void ShowDisabled();

    bool ScrollToAnchor(const wxString& anchor);

protected:
};

/**
    @class wxTTSCustomPronunciationDialog
    
    @category{tts}
 */

class wxTTSCustomPronunciationDialog: public wxDialog
{    
    DECLARE_DYNAMIC_CLASS( wxTTSCustomPronunciationDialog )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    wxTTSCustomPronunciationDialog();
    wxTTSCustomPronunciationDialog( wxTTSTransformer* transformer, wxWindow* parent, wxWindowID id = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_IDNAME, const wxString& caption = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_POSITION, const wxSize& size = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_SIZE, long style = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_STYLE );

    /// Creation
    bool Create( wxTTSTransformer* transformer, wxWindow* parent, wxWindowID id = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_IDNAME, const wxString& caption = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_TITLE, const wxPoint& pos = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_POSITION, const wxSize& size = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_SIZE, long style = SYMBOL_WXTTSCUSTOMPRONUNCIATIONDIALOG_STYLE );

    /// Destructor
    ~wxTTSCustomPronunciationDialog();

    /// Initialises member variables
    void Init();

    /// Creates the controls and sizers
    void CreateControls();

    /// List words
    void FillWordList();

    /// Show given word
    void ShowWord(int i);

    /// Get speech object
    wxTextToSpeech* GetSpeech() const { return m_speech; }
    
    /// Set speech object
    void SetSpeech(wxTextToSpeech* speech) { m_speech = speech; }

    /// Set/get tooltip show flag
    static void SetShowToolTips(bool show) { m_showToolTips = show; }
    static bool GetShowToolTips() { return m_showToolTips; }
    
////@begin wxTTSCustomPronunciationDialog event handler declarations

    /// wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_CUSTOM_WORD_LISTBOX
    void OnCustomWordListboxSelected( wxCommandEvent& event );

    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ADD_CUSTOM_WORD
    void OnAddCustomWordClick( wxCommandEvent& event );

    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_REMOVE_CUSTOM_WORD
    void OnRemoveCustomWordClick( wxCommandEvent& event );

    /// wxEVT_UPDATE_UI event handler for ID_REMOVE_CUSTOM_WORD
    void OnRemoveCustomWordUpdate( wxUpdateUIEvent& event );

    /// wxEVT_UPDATE_UI event handler for ID_CUSTOM_WORD
    void OnCustomWordUpdate( wxUpdateUIEvent& event );

    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CUSTOM_WORD_SAY
    void OnCustomWordSayClick( wxCommandEvent& event );

    /// wxEVT_UPDATE_UI event handler for ID_CUSTOM_WORD_SAY
    void OnCustomWordSayUpdate( wxUpdateUIEvent& event );

    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_CUSTOM_REPLACEMENT
    void OnCustomReplacementTextUpdated( wxCommandEvent& event );

    /// wxEVT_UPDATE_UI event handler for ID_CUSTOM_REPLACEMENT
    void OnCustomReplacementUpdate( wxUpdateUIEvent& event );

    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CUSTOM_REPLACEMENT_SAY
    void OnCustomReplacementSayClick( wxCommandEvent& event );

    /// wxEVT_UPDATE_UI event handler for ID_CUSTOM_REPLACEMENT_SAY
    void OnCustomReplacementSayUpdate( wxUpdateUIEvent& event );

////@end wxTTSCustomPronunciationDialog event handler declarations

////@begin wxTTSCustomPronunciationDialog member function declarations

    /// Retrieves bitmap resources
    wxBitmap GetBitmapResource( const wxString& name );

    /// Retrieves icon resources
    wxIcon GetIconResource( const wxString& name );
////@end wxTTSCustomPronunciationDialog member function declarations

    /// Should we show tooltips?
    static bool ShowToolTips();

////@begin wxTTSCustomPronunciationDialog member variables
    wxBoxSizer* m_innerSizer;
    wxListBox* m_wordListCtrl;
    wxTextCtrl* m_customWordCtrl;
    wxTextCtrl* m_replacementWordCtrl;
    wxTTSHtmlWindow* m_htmlWindow;
    /// Control identifiers
    enum {
        ID_CUSTOMPRONUNCIATIONDIALOG = 22700,
        ID_CUSTOM_WORD_LISTBOX = 22701,
        ID_ADD_CUSTOM_WORD = 22702,
        ID_REMOVE_CUSTOM_WORD = 22703,
        ID_CUSTOM_WORD = 22704,
        ID_CUSTOM_WORD_SAY = 22705,
        ID_CUSTOM_REPLACEMENT = 22706,
        ID_CUSTOM_REPLACEMENT_SAY = 22707,
        ID_CUSTOM_PRONUNCIATION_HTMLWINDOW = 22708
    };
////@end wxTTSCustomPronunciationDialog member variables

    wxTTSTransformer*           m_transformer;
    bool                        m_ignoreEvents;
    wxTextToSpeech*             m_speech;
    static bool                 m_showToolTips;
};

#endif
    // _CUSTOMPRONUNCIATIONDIALOG_H_
